/*--------------------------------------------------------------
 * File: demo45.c 编码类型：C语言  UTF-8
 * Author WRS (1352509846@qq.com)
 * 功能: 计算数组元素之和（循环输出数组元素）
 * Version 0.1
 * Date 2022-07-10 
 * 
 * @copyright Copyright (c) 2022
 * 
----------------------------------------------------------------*/

#include <stdio.h>

int main(int argc, char const *argv[])
{
    int array[] = {1,2,3,4,5,6,7,8};
    int sum = 0;
    
    for(int i=0; i<sizeof(array)/sizeof(int); i++)
    {
        printf("%d ",array[i]);
        sum += array[i];
    }
    printf("\nsum = %d\n",sum);

    return 0;
}
